/*
 * at_list.h
 *
 *  Created on: 202211/7
 *      Author: yanghx
 */

#include "module_config.h"

#define AT_VERSION          2.0

#define PARAM_MAX_NUM      10

typedef enum
{
    PIN_ID_EDGE_OVERCURRENT = 0,
    PIN_ID_CPU_TO_MCU_IO,
    PIN_ID_MCU_TO_SOM_PWRON,
    PIN_ID_EDGE_ALIGN_DETECT,
    PIN_ID_MOTOR_POWER_DISABLE,
    
    PIN_ID_I2C_SCL,
    PIN_ID_I2C_SDA,
    PIN_ID_BAT_SW_EN,
    // add below,not delete up or insert up
    PIN_ID_MOTOR_OVERCURRENT_DETECT,

    
    PIN_ID_MAX,
}en_PinId;

typedef enum
{
    RECOVER_ID_EDGE_OCD = 0,
    RECOVER_ID_MOTOR_POWER_RELEASE,
    // add below,not delete up or insert up
    RECOVER_ID_MOTOT_RELEASE,

    RECOVER_ID_MAX,
}en_RecoverId;

// for status query
struct __CommStatus {
    //up tx
    uint64_t  uptx_total;    // bytes
    uint32_t  uptx_ovtimes;
    
    //up rx
    uint64_t  uprx_total;
    //uint32_t  uprx_ovtimes;
    
    // down tx
    uint64_t  downtx_total;
    uint32_t  downtx_ovtimes;
    
    // donw rx
    uint64_t  downrx_total;
    //uint32_t  downrx_ovtimes;
};
extern struct __CommStatus  stMonitor;


//subg test 
typedef struct
{
	uint8_t test_mode;
    uint8_t retMode;
    uint8_t subG_update;
    uint8_t subG_power;
	uint8_t subG_channel;
	uint8_t subG_txrx;
	int16_t subG_TxRSSI;
	int16_t subG_RxRSSI;
	uint32_t subG_id;
	uint8_t *subG_data;
}SubBTestTypedef;

typedef struct
{
	uint8_t tx_mode;
    uint8_t rx_mode;
    uint8_t emc_channel;

}emcTestTypedef;

extern SubBTestTypedef g_SubGTest;
extern uint8_t g_i2cGpioTest;
extern uint8_t Bat_sw_en_flag;

uint8_t get_fac_mode_en(void);
void set_sub_com_test(uint8_t value);
uint8_t get_sub_com_test(void);
int sub_com_test(uint32_t u32Port, char *param);

int at_version(uint32_t u32Port, char *param);
int enter_fac(uint32_t u32Port, char *param);
int exit_fac(uint32_t u32Port, char *param);
int fw_ver_read(uint32_t u32Port, char *param);
int boot_ver_read(uint32_t u32Port, char *param);
int hardware_id_read(uint32_t u32Port, char *param);
int dev_reset(uint32_t u32Port, char *param);
int gpio_test(uint32_t u32Port, char *param);
int sub_test_en(uint32_t u32Port, char *param);
int sub_para_config(uint32_t u32Port, char *param);
int sub_test_ext(uint32_t u32Port, char *param);
int sub_test_tx(uint32_t u32Port, char *param);
int sub_ret_val(uint32_t u32Port, char *param);
int mem_read(uint32_t u32Port, char *param);
int mem_write(uint32_t u32Port, char *param);
int log_ctrl(uint32_t u32Port, char *param);
int log_level_set(uint32_t u32Port, char *param);
int log_level_get(uint32_t u32Port, char *param);
int module_log_level_set(uint32_t u32Port, char *param);
int pn_write(uint32_t u32Port, char *param);
int sn_write(uint32_t u32Port, char *param);
int matchpn_write(uint32_t u32Port, char *param);
int pn_read(uint32_t u32Port, char *param);
int matchpn_read(uint32_t u32Port, char *param);
int buzzer_test(uint32_t u32Port, char *param);
int hall_read(uint32_t u32Port, char *param);
int key_read(uint32_t u32Port, char *param);
#ifdef LIFT_MOTOR
int lift_motor_test(uint32_t u32Port, char *param);
#endif

#ifdef TCU_MODULE
int tcu_com_test(uint32_t u32Port, char *param);
#endif
int uart_up_test(uint32_t u32Port, char *param);
int sub_cfg_write(uint32_t u32Port, char *param);
// int sub_cfg_read(uint32_t u32Port, char *param);
int subg_read(uint32_t u32Port, char *param);
int subgPair(uint32_t u32Port, char *param);
int subgDeletePairID(uint32_t u32Port, char *param);
int get_bat_info(uint32_t u32Port, char *param);
int charge_ctrl(uint32_t u32Port, char *param);
int charge_i_pwm(uint32_t u32Port, char *param);
int charge_v_pwm(uint32_t u32Port, char *param);
//int charge_cur(uint32_t u32Port, char *param);
//int charge_vol(uint32_t u32Port, char *param);
int charge_cur_config(uint32_t u32Port, char *param);
int charge_vol_config(uint32_t u32Port, char *param);
int ntc_read(uint32_t u32Port, char *param);
int other_mcu_reset(uint32_t u32Port, char *param);
int set_lift_motor_hight(uint32_t u32Port, char *param);
int quality_test_mowing_motor(uint32_t u32Port, char *param);
int power_switch(uint32_t u32Port, char *param);
#ifdef TCU_MODULE
int tcu_ctrl_test(uint32_t u32Port, char *param);
#endif
int get_other_at_version(uint32_t u32Port, char *param);

#ifdef TCU_MODULE
int fac_tcu_error_inject(uint32_t u32Port, char *param);
#ifdef TCU_LINK_TEST_ENABLE
int fac_tcu_link_test(uint32_t u32Port, char *param);
#endif
#endif

#if 1
int hall_read_value(uint32_t u32Port, char *param);
#endif

int cpu_id_read(uint32_t u32Port, char *param);
int sign_read(uint32_t u32Port, char *param);
int sign_write(uint32_t u32Port, char *param);
int power_good_read(uint32_t u32Port, char *param);
int volt_read(uint32_t u32Port, char *param);
int adc_volt_read(uint32_t u32Port, char *param);
int current_read(uint32_t u32Port, char *param);
int pin_read(uint32_t u32Port, char *param);
int pin_write(uint32_t u32Port, char *param);
int recover_ctrl(uint32_t u32Port, char *param);
int i2cGPIOtest(uint32_t u32Port, char *param);
int flash_info_read(uint32_t u32Port, char *param);
// int rain_level_set(uint32_t u32Port, char *param);
int get_cell_infor(uint32_t u32Port, char *param);
int motor_test(uint32_t u32Port, char *param);
int motor_direct_test(uint32_t u32Port, char *param);
int motor_RPM_test(uint32_t u32Port, char *param);
int motor_read_status(uint32_t u32Port, char *param);
int dev_powerdown(uint32_t u32Port, char *param);
int display_test(uint32_t u32Port, char *param);
#ifdef BSP_FLASH_UNIT_TEST_EN
int factory_flash_test(uint32_t u32Port, char *param);
#endif
int read_backmotor_assit_flag(uint32_t u32Port, char *param);
int errorcode_test(uint32_t u32Port, char *param);
int power_on_source_read(uint32_t u32Port, char *param);
int dc_in_ctrl(uint32_t u32Port, char *param);
int imu_state_ret(uint32_t u32Port, char *param);
int get_motor_state(uint32_t u32Port, char *param);
int rgb_led_test(uint32_t u32Port, char *param);

int EMC_TX_Test(uint32_t u32Port, char *param);
int EMC_RX_Test(uint32_t u32Port, char *param);
int emc_test_enter(uint32_t u32Port, char *param);
